package com.snopy.designPattern.create.builder;

import com.snopy.designPattern.create.builder.element.Chip;
import com.snopy.designPattern.create.builder.element.Outward;
import com.snopy.designPattern.create.builder.element.Screen;
import com.snopy.enums.ScreenEnum;

/**
 * @author snopy
 * @version 1.0.0
 * @classname Director
 * @description
 * @email 77912204@qq.com
 * @date 2022/03/01 20:55
 */
public class Director implements Cloneable{
    private final Builder builder = new PhoneBuild();
    public Phone createPhone(Integer size, ScreenEnum screenType){
        Chip chip = new Chip();
        chip.setSize(size);
        chip.setBrand("HUAWEI");
        chip.setVersion("HONGMENGOS 2.0.0");
        Outward outward = new Outward();
        Screen screen = new Screen();
        this.builder.buildChip(chip).buildOutward(outward).buildScreen(screen);
        return builder.getPhone();
    }

    @Override
    public Director clone() {
        try {
            // TODO: copy mutable state here, so the clone can't change the internals of the original
            return (Director) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
